<!-- 模板 -->
<template>
  <div class="file">
      <el-tabs v-model="listParams.type" @tab-click="handleClick">
      <el-tab-pane label="关于我们" name="1">
        <el-button type="primary" @click="onSubmit" style="margin-bottom:20px">保 存</el-button>
        <el-form :model="form1">
            <el-form-item  style="height:200px">
                <quill-editor 
                v-model="form1.content" 
                ref="myQuillEditor" 
                :options="editorOption"
                style="height:150px" >
                </quill-editor>
            </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="团体测量咨询介绍" name="2">
        <el-button type="primary" @click="onSubmit" style="margin-bottom:20px">保 存</el-button>
        <el-form :model="form2">
            <el-form-item  style="height:200px">
                <quill-editor 
                v-model="form2.content" 
                ref="myQuillEditor" 
                :options="editorOption"
                style="height:150px" >
                </quill-editor>
            </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="分销商咨询介绍" name="3">
        <el-button type="primary" @click="onSubmit" style="margin-bottom:20px">保 存</el-button>
        <el-form :model="form3">
            <el-form-item  style="height:200px">
                <quill-editor 
                v-model="form3.content" 
                ref="myQuillEditor" 
                :options="editorOption"
                style="height:150px" >
                </quill-editor>
            </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="报考证书介绍" name="4">
        <el-button type="primary" @click="onSubmit" style="margin-bottom:20px">保 存</el-button>
        <el-form :model="form4">
            <el-form-item  style="height:200px">
                <quill-editor 
                v-model="form4.content" 
                ref="myQuillEditor" 
                :options="editorOption"
                style="height:150px" >
                </quill-editor>
            </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="注册协议" name="5">
        <el-button type="primary" @click="onSubmit" style="margin-bottom:20px">保 存</el-button>
        <el-form :model="form5">
            <el-form-item  style="height:200px">
                <quill-editor 
                v-model="form5.content" 
                ref="myQuillEditor" 
                :options="editorOption"
                style="height:150px" >
                </quill-editor>
            </el-form-item>
        </el-form>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import {getMeasure,getMeasureDsc} from '@/api/teacher/index'
export default {
  name: '',
  data () {
    return {
        editorOption:{
          modules:{
                toolbar:[
                  ['bold', 'italic', 'underline', 'strike'],
                  [{ 'size': ['small', false, 'large', 'huge'] }],
                  [{ 'list': 'ordered'}, { 'list': 'bullet' }],
                  [{ 'color': [] }, { 'background': [] }], 
                  [{ 'direction': 'rtl' }],
                  [{ 'indent': '-1'}, { 'indent': '+1' }],
                ]
            }
        },
        listParams:{
            type:'1'
        },
        form1:{
          type:1,
          id:undefined
        },
        form2:{
          type:2,
          id:undefined
        },
        form3:{
          type:3,
          id:undefined
        },
        form4:{
          type:4,
          id:undefined
        },
        form5:{
          type:5,
          id:undefined
        },
    }
  },
  props: [],
  components: {},
  computed: {},
  filters: {},
  methods: {
      onSubmit(){
        if(this.listParams.type == 1){
          getMeasure(this.form1).then(res =>{
          if(res.code == 200){
            // console.log(res);
            this.$message.success("保存成功")
          }
        })
        }else if(this.listParams.type == 2){
          getMeasure(this.form2).then(res =>{
          if(res.code == 200){
            // console.log(res);
            this.$message.success("保存成功")
          }
        })
        }else if(this.listParams.type == 3){
          getMeasure(this.form3).then(res =>{
          if(res.code == 200){
            // console.log(res);
            this.$message.success("保存成功")
          }
        })
        }else if(this.listParams.type == 4){
          getMeasure(this.form4).then(res =>{
          if(res.code == 200){
            // console.log(res);
            this.$message.success("保存成功")
          }
        })
        }else if(this.listParams.type == 5){
          getMeasure(this.form5).then(res =>{
          if(res.code == 200){
            // console.log(res);
            this.$message.success("保存成功")
          }
        })
        }
        
      },
      handleClick(val){
        this.getlist()
      },
      // 获取详情
      getlist(){
        if(this.listParams.type == 1){
          let data = {
            type:1
          }
          getMeasureDsc(data).then(res => {
          if(res.code == 200){
            this.form1 = res.data
            // this.form1.id = res.data.id
          }
        })
        }
        else if(this.listParams.type == 2){
          let data = {
            type:2
          }
          getMeasureDsc(data).then(res => {
          if(res.code == 200){
            this.form2 = res.data
            console.log(res);
          }
        })
        }else if(this.listParams.type == 3){
          let data = {
            type:3
          }
          getMeasureDsc(data).then(res => {
          if(res.code == 200){
            this.form3 = res.data
            console.log(res);
          }
        })
        }else if(this.listParams.type == 4){
          let data = {
            type:4
          }
          getMeasureDsc(data).then(res => {
          if(res.code == 200){
            this.form4 = res.data
            console.log(res);
          }
        })
        }else if(this.listParams.type == 5){
          let data = {
            type:5
          }
          getMeasureDsc(data).then(res => {
          if(res.code == 200){
            this.form5 = res.data
            console.log(res);
          }
        })
        }
        
      },
  },
  created () {
    this.getlist()
  },
  mounted () {}
}
</script>

<style >
.file{
    padding: 20px 20px 40px 20px;
  }
</style>
